package com.lagou.service.impl;

import com.lagou.dao.ArticleDao;
import com.lagou.pojo.Article;
import com.lagou.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author caiwei
 * @date 2020-10-6 16:20
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleDao articleDao;

    @Override
    public Page<Article> listArticlesByPage(int page, int pageSize) {
        Pageable pageable = PageRequest.of(page, pageSize);
        return articleDao.findAll(pageable);
    }
}
